﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Model;
namespace DAL
{
   public class 主界面DAL
    {
        //查所有房间类型
       public static List<RoomType> RoomType()
       {
            string sql = "select * from RoomType";
            SqlDataReader dr = DBHelper.Zhilianshi(sql, null);
            List<RoomType> l = new List<RoomType>();
            while (dr.Read())
            {
                RoomType m = new RoomType();
                m.RTID = Convert.ToInt32(dr["RTID"].ToString());
                m.RName = dr["RTName"].ToString();
                m.RTConsume = Convert.ToDouble(dr["RTConsume"].ToString());
                m.RTIsDisCount = Convert.ToBoolean(dr["RTIsDisCount"].ToString());
                m.RTMount = Convert.ToInt32(dr["RTMount"].ToString());
                l.Add(m);
            }
            return l;
        }
       //查询对应的图片
       public static DataTable query(Tables tab) {
           string sql = "select * from Tables  where RTID=@RTID";
           List<SqlParameter> list = new List<SqlParameter>()
           {
               new SqlParameter("@RTID",tab.RTID)
           };
           return DBHelper.Dataset(sql,list);
       }
       //右键功能修改状态
       public static int TableState(Tables tab)
       {
           string sql = "Update Tables set TableState=@TableState where TableID =@TableID";
           List<SqlParameter> list = new List<SqlParameter>()
           {
               new SqlParameter("@TableState",tab.TableState),
               new SqlParameter("@TableID",tab.tableID)
           };
           return DBHelper.Update(sql,list.ToArray());

       }
    }
}
